//C++11 introduces a range-base iterative method

#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    std::vector<int> vec = {1, 2, 3, 4};
    //找到vec中第一个值为3的数，并将其值改为4
    if (auto itr = std::find(vec.begin(), vec.end(), 3); itr != vec.end())
        *itr = 4;
    for (auto element : vec) 
        std::cout << element << " "; //read only
    std::cout<<std::endl;
    for (auto &element : vec) {
        element += 1;                //writealble
    }
    for (auto element : vec) {
        std::cout << element << " "; //read only
    }
    std::cout<<std::endl;

    return 0;
}